package com.miku.blog.handler.security;

import com.miku.blog.eume.HttpStatusEnum;
import com.miku.blog.utils.WebUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author shkstart
 * @create ${}YEAR-05-25 0:31
 */
@Deprecated
@Slf4j
public class AccessDeniedHandlerImpl implements AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
        log.error(">>>>> 访问权限不足 <<<<<");
        log.error(accessDeniedException.getMessage());
        WebUtils.sendResponseResult(response,HttpStatusEnum.FORBIDDEN);
        log.error(">>>>> END <<<<<" + System.lineSeparator());
    }
}
